import os


# 返回路径文件名及目录名 typeNum 0:文件名 1:目录名 2:返回 目录/文件名 3:返回文件名不带后缀
def backFileNameAndFolderName(pathStr, typeNum):
    if typeNum == 1:
        folderPath = os.path.dirname(pathStr)
        name = os.path.basename(folderPath)
    elif typeNum == 0:
        name = os.path.basename(pathStr)
    elif typeNum == 3:
        name = os.path.basename(pathStr).split(".")[0]
    else:
        name = backFileNameAndFolderName(pathStr, 1) + "/" + backFileNameAndFolderName(pathStr, 0)
    return name
